<?php
/*
 * ================================================= Managing Topic =======================================
 * Author 			: Nguyen Minh Tuan
 * Created Date		: 22/08/2011
 * Modified Date	: 22/08/2011
 */

	/*
	 * insert record to table topic
	 */
	function SO_topic_insert(){
		$query = "
					INSERT INTO `topic` (
						`subject`		,
						`description`	,
						`parent`		,
						`log`			,
						`insert`
					) VALUES (
						" . (	$_REQUEST[ "txt_subject" 	] ? "'" . $_REQUEST[ "txt_subject"		] . "'" : "NULL" )	. ",
						" . (	$_REQUEST[ "ta_description" ] ? "'" . $_REQUEST[ "ta_description"	] . "'" : "NULL" )	. ",
						" . (	$_REQUEST[ "cb_parent"		] ? " " . $_REQUEST[ "cb_parent"		] . " " : "0" )		. ",
						CONCAT( NOW( ), ' " . $_SESSION[ "JO_account_key" ] . "\r\n' ),
						NOW()
					)
				";
		
		JO_query( $query );
		JO_location( );
	}
	
	/*
	 * Update record to table topic
	 */
	function SO_topic_update(){
		$query = "
				UPDATE `topic` SET
					`subject`		= " . (	$_REQUEST[ "txt_subject"	] ? "'" . $_REQUEST[ "txt_subject"		] . "'" : "NULL"	) . ",
					`description`	= " . (	$_REQUEST[ "ta_description"	] ? "'" . $_REQUEST[ "ta_description"	] . "'" : "NULL"	) . ",
					`parent`		= " . (	$_REQUEST[ "cb_parent"		] ? "'" . $_REQUEST[ "cb_parent"		] . "'" : "0"		) . ",
					`log`			= CONCAT( `log`, NOW( ), ' " . $_SESSION[ "JO_account_key" ] . "\r\n' ),
					`update`		= NOW( )
					WHERE `key`		= " .	$_REQUEST[ "SO_index_key"		] . "			
			";

			JO_query( $query );
			JO_location( );
	}
	
/*
 * ================================================= End Managing Topic =======================================
 */
?>